package com.alphaking.controller.admin;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alphaking.service.mingweicai.BlogService;
import com.alphaking.util.DataConvertorUtil;

@Controller
public class BlogUpdateController {

	@Resource
	private BlogService blogService;

	@RequestMapping("/admin/toUpdateBlogPage")
	public String toUpdateBlogPage(Model model, String id) throws NoSuchFieldException, SecurityException {

		blogService.findBlog(id, model);
		blogService.initCategorys(model);
		return "/admin/blogUpdate";
	}

	@RequestMapping("/admin/updateBlog")
	public String updateBlog(Model model, String mapAttr) throws NoSuchFieldException, SecurityException {

		System.out.println(mapAttr);
		blogService.updateBlog(mapAttr);

		return "redirect:/admin/toBlogListPage";
	}

}
